package com.example.fms.controller;

import com.example.fms.dto.req.ArithmeticInfoReqDto;
import com.example.fms.dto.req.MinOrderRuleReqDto;
import com.example.fms.service.ArithmeticLogInfoService;
import com.example.fms.vo.ResponseBean;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.InputMismatchException;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

@Validated
@RestController
@RequestMapping("/arithmetic")
public class ArithmeticLogInfoController {
    @Resource
    ArithmeticLogInfoService arithmeticLogInfoService;

    /**
     * 单条计算
     * @param req 单据信息
     * @return 计算结果
     */
    @PostMapping("/getArithmeticInfo")
    public ResponseBean<Map<String, Integer>> getArithmeticInfo(@RequestBody @Valid ArithmeticInfoReqDto req) {
        return ResponseBean.success(arithmeticLogInfoService.getArithmeticInfo(req));
    }

    /**
     * 批量计算
     * @param req 批量单据
     * @return 计算结果
     */
    @PostMapping("/getArithmeticInfoList")
    public ResponseBean<Map<String, String>> getArithmeticInfoList(@RequestBody @Valid List<ArithmeticInfoReqDto> req) {
        return ResponseBean.success(arithmeticLogInfoService.getArithmeticInfoList(req));
    }

}








